import request from "@/utils/req";

//获取角色列表
export function getRoleListApi(params) {
  return request({
    url: "/sys/role",
    method: "get",
    params,
  });
}

// 新增角色
export function addRoleApi(data) {
  return request({
    url: "/sys/role",
    method: "post",
    data,
  });
}
// 编辑角色
export function editRoleApi(data) {
  return request({
    url: `/sys/role/${data.id}`,
    method: "put",
    data, //查询参数
  });
}

// 删除角色
export function deleteRoleApi(id: string) {
  return request({
    url: `/sys/role/${id}`,
    method: "delete",
  });
}

//获取已启用的角色列表
export function getEnabledRoleListApi() {
  return request({
    url: "/sys/role/list/enabled",
    method: "get",
  });
}

//获取角色详情
export function getRoleDetailApi(id) {
  return request({
    url: `/sys/role/${id}`,
    method: "get",
  });
}

//分配员工角色
export function assignRolesApi(data) {
  return request({
    url: "/sys/user/assignRoles",
    method: "put",
    data,
  });
}

/**
 * 给角色分配权限
 *
 * ***/

export function assignPermApi(data) {
  return request({
    url: "/sys/role/assignPrem",
    method: "put",
    data,
  });
}
